<?php

/**
 * This is the model class for table "rentalunit".
 *
 * The followings are the available columns in table 'rentalunit':
 * @property integer $id
 * @property integer $idRentalProperty
 * @property string $UnitNumber
 * @property string $SoftwareUnitCode
 * @property integer $RentalAmount
 * @property string $SubsidizedRent
 * @property string $IncomeQualifiedUnit
 * @property string $WaterSewerIncluded
 * @property string $HeatIncluded
 * @property string $ElectricIncluded
 *
 * The followings are the available model relations:
 * @property Rentalproperty $idRentalProperty0
 */
class Rentalunit extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @return Rentalunit the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'rentalunit';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('idRentalProperty, RentalAmount', 'numerical', 'integerOnly'=>true),
			array('UnitNumber', 'length', 'max'=>10),
			array('SoftwareUnitCode', 'length', 'max'=>15),
			array('SubsidizedRent, IncomeQualifiedUnit, WaterSewerIncluded, HeatIncluded, ElectricIncluded', 'length', 'max'=>3),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('id, idRentalProperty, UnitNumber, SoftwareUnitCode, RentalAmount, SubsidizedRent, IncomeQualifiedUnit, WaterSewerIncluded, HeatIncluded, ElectricIncluded', 'safe', 'on'=>'search'),
			array('idRentalProperty, RentalAmount, UnitNumber', 'required'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
			'idRentalProperty0' => array(self::BELONGS_TO, 'Rentalproperty', 'idRentalProperty'),
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'id' => 'ID',
			'idRentalProperty' => 'Id Rental Property',
			'UnitNumber' => 'Unit Number',
			'SoftwareUnitCode' => 'Software Unit Code',
			'RentalAmount' => 'Rental Amount',
			'SubsidizedRent' => 'Subsidized Rent',
			'IncomeQualifiedUnit' => 'Income Qualified Unit',
			'WaterSewerIncluded' => 'Water Sewer Included',
			'HeatIncluded' => 'Heat Included',
			'ElectricIncluded' => 'Electric Included',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('id',$this->id);
		$criteria->compare('idRentalProperty',$this->idRentalProperty);
		$criteria->compare('UnitNumber',$this->UnitNumber,true);
		$criteria->compare('SoftwareUnitCode',$this->SoftwareUnitCode,true);
		$criteria->compare('RentalAmount',$this->RentalAmount);
		$criteria->compare('SubsidizedRent',$this->SubsidizedRent,true);
		$criteria->compare('IncomeQualifiedUnit',$this->IncomeQualifiedUnit,true);
		$criteria->compare('WaterSewerIncluded',$this->WaterSewerIncluded,true);
		$criteria->compare('HeatIncluded',$this->HeatIncluded,true);
		$criteria->compare('ElectricIncluded',$this->ElectricIncluded,true);

		return new CActiveDataProvider(get_class($this), array(
			'criteria'=>$criteria,
		));
	}
}